<?php
namespace App\Http\Controllers\Api\V2\RedEnvelope;

use App\Http\Controllers\ApiController;
use App\Http\Controllers\Business\Common\RedEnvelopeManagement;



class RedEnvelopeController extends ApiController
{
    //领取红包
    public function getEnvelope() {
        $userId = $this->userId;
        $cityId = $this->request->get('cityid');
        $position = $this->request->get('position');
        if($this->request->has('content')) {
            $content = $this->request->get('content');
        } else {
            $content = '';
        }
        $data = [];
        if($position == 'order') {
            $result = RedEnvelopeManagement::getOrderRedEnvelope($userId, $cityId, $content);
        } elseif($position == 'recharge') {
            $result = [];
        } elseif($position == 'index') {
            $result = [];
        } elseif($position == 'h5') {
            $result = [];
        } else {
            return $this->responseSuccessData([]);
        }
        if(isset($result['status']) && ($result['status'] == 'success')) {
            $data = $result['data'];
        }
        return $this->responseSuccessData($data);
        /*
        $data = [
            [
                'redenvelopeid'=>1,
                'amount' => 8.60,
                'minimumamount' => 0.00,
                'endtime' => '2017-03-15',
                'usetime' => '',
                'status' => 0,
                'cityid' => 1,
                'cityname' => '南昌市',
                'firstclassid' => 0,
                'secondclassid' => 0,
                'firstclassname' => '',
                'secondclassname' => ''
            ],
            [
                'redenvelopeid'=>2,
                'amount' => 9.60,
                'minimumamount' => 0.00,
                'endtime' => '2017-03-16',
                'usetime' => '',
                'status' => 0,
                'cityid' => 1,
                'cityname' => '南昌市',
                'firstclassid' => 0,
                'secondclassid' => 0,
                'firstclassname' => '',
                'secondclassname' => ''
            ],
        ];
        return $this->responseSuccessData($data);
        */
    }

}